# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer: Eric Belanger <belanger@astro.umontreal.ca>
# Contributor: Link Dupont <link@subpop.net>

pkgname=xloadimage
pkgver=4.1
pkgrel=16
pkgdesc="An utility to view many different types of images under X11"
arch=(loong64 x86_64)
url="https://sioseis.ucsd.edu/xloadimage.html"
license=("MIT")
depends=('libtiff' 'libpng' 'libx11' 'libxext')
makedepends=('patch' 'imake')
source=(https://arch.p5n.pp.ru/~sergej/dl/2018/xloadimage.$pkgver-1.tar.gz
	license.txt
	enable-image-types.patch
	png15-tiff4.patch)
sha256sums=('0e97ebb57a0666f604bcb29c72018c15ca59b743ddf7d5fdccc05892e52695fb'
            'db7d013cfa6cdd8c695e4bbc5152c49a3acc7eab7f5c3e5f5d9d87828658c9a7'
            '54755994f787287b94be156c9e3f82c4214172636488e243039ccf9bdaab2b74'
            '91ddbf7f8575245634f4fbd05fa28c9e9bb941d4067176ca75d85089c07982c8')

build() {
  cd "$srcdir"/$pkgname.$pkgver

  patch -p1 <"$srcdir"/enable-image-types.patch
  patch -p1 <"$srcdir"/png15-tiff4.patch
  xmkmf
  make
}

package() {
  cd "$srcdir"/$pkgname.$pkgver

  install -D -m755 xloadimage "$pkgdir"/usr/bin/xloadimage
  install -D -m755 uufilter "$pkgdir"/usr/bin/uufilter
  install -D -m644 xloadimagerc "$pkgdir"/etc/xloadimagerc.example
  install -D -m644 xloadimage.man "$pkgdir"/usr/man/man1/xloadimage.1x
  install -D -m644 uufilter.man "$pkgdir"/usr/man/man1/uufilter.1x
  install -D -m644 "$srcdir"/license.txt "$pkgdir"/usr/share/licenses/$pkgname/license.txt
  ln -s /usr/bin/xloadimage "$pkgdir"/usr/bin/xsetbg

  mv "$pkgdir"/usr/man "$pkgdir"/usr/share/
}
